package com.hmall.controller;

import com.hmall.common.pojo.PageDTO;
import com.hmall.pojo.ItemDoc;
import com.hmall.pojo.Param;
import com.hmall.service.SearchServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author 15198
 * @Date 2022/8/10 15:48
 * @Description:
 * @Created by
 */
@RestController
@RequestMapping("/search")
public class searchController {


    @Autowired
    private SearchServiceImpl searchService;

    /**
     * 商品分页展示
     * @param params
     * @return
     */
    @PostMapping("/list")
    public PageDTO<ItemDoc> search(@RequestBody Param params) {
        return searchService.search(params);
    }


    /**
     * 商品搜索自动补全
     * @param key
     * @return
     */
    @GetMapping("/suggestion")
    public List<String> suggestion(@RequestParam("key") String key) {
        return searchService.suggestion(key);
    }



    @PostMapping("/filters")
    public Map<String,List<String>> filters(@RequestBody Param param){


        return  searchService.filter(param);


    }
}
